// Released in the Public Domain. http://creativecommons.org/licenses/publicdomain/
package org.xi8ix.async;

import java.nio.ByteBuffer;
import java.net.InetSocketAddress;

/**
 * A single listener should be registered to receive incoming data.
 * Processing of the data should be very fast or it will tie up the server's i/o thread.
 * In most cases, data should be lightly proccessed (blacklisting, etc) and then enqueued
 * for worker threads to handle using a java.util.concurrent.Executor or similar threading
 * library.
 *
 * @author Iain Shigeoka
 */
public interface Receiver {
    /**
     * Called when data is received.
     *
     * @param data the data that was received
     * @param src the host and port from which the message was sent.  The source is not
     * authenticated; the value is simply copied from the IP packet header.
     * @param dest the host and port to which the message was sent. The destination is
     * not authenticated; the walue is simply copied from the IP packet header.
     */
    void onRecv(ByteBuffer data, InetSocketAddress src, InetSocketAddress dest);
}
